﻿using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace delitel.ViewModel
{
    internal abstract class MainViewModel:INotifyPropertyChanged, IDisposable
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void NotyfyPropertyChanded([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        protected virtual bool Set<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
        {
            if (Equals(field, value)) return false;
            field = value;
            NotyfyPropertyChanded(propertyName);
            return true;
        }
        //~MainViewModel()
        //{
        //    Dispose(false);
        //}
       

        public void Dispose()
        {
            Dispose(true);
        }
        private bool _Disposed;
        protected virtual void Dispose(bool Disposing)
        {
            if (!Disposing || _Disposed) return;
            _Disposed = true;
            //освобождение управляемых ресурсов


        }

        
    }
}
